import type { ParamsType } from '#/views/system/params/params.data.ts';

import { requestClient } from '#/api/request';

export namespace SysParamsTableApi {
  export type RowTypeFetchParams = ParamsType;
  export interface IdFetchParams {
    id: string;
  }
  export interface ListFetchParams {
    [key: string]: any;
  }
  export interface PageListFetchParams {
    [key: string]: any;
    pageNo: number;
    pageSize: number;
  }
}

/**
 * 分页列表查询
 */
export async function sysParamsQueryPageListApi(
  params: SysParamsTableApi.PageListFetchParams,
) {
  return requestClient.get('/system/sysParams/queryPageList', { params });
}

/**
 * 列表查询
 */
export async function sysParamsQueryListApi(
  params: SysParamsTableApi.ListFetchParams,
) {
  return requestClient.get('/system/sysParams/queryList', { params });
}

/**
 * 通过ID查询
 * @param params
 */
export async function sysParamsQueryByIdApi(
  params: SysParamsTableApi.IdFetchParams,
) {
  return requestClient.get('/system/sysParams/queryById', { params });
}

/**
 * 新增
 */
export async function sysParamsAddApi(
  params: SysParamsTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/system/sysParams/add', params);
}

/**
 * 编辑
 */
export async function sysParamsEditApi(
  params: SysParamsTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/system/sysParams/edit', params);
}

/**
 * 删除
 * @param id 主键
 */
export async function sysParamsDelApi(id) {
  return requestClient.delete<boolean>(`/system/sysParams/delete/${id}`);
}

/**
 * 批量删除删除
 * @param ids 主键
 */
export async function sysParamsDeleteBatchApi(ids) {
  return requestClient.delete<boolean>(
    `/system/sysParams/deleteBatchByIds/${ids}`,
  );
}

/**
 * 保存配置值
 * @param data 配置数据
 */
export async function sysParamsEditValApi(data) {
  return requestClient.post('/system/sysParams/editVal', data);
}
